<%@ page contentType="text/html; charset=UTF-8" language="java" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% String path=request.getContextPath(); %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en" >
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, stu-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>用户列表 - BsAdmin后台模板 - 经典版演示</title>
    <link rel="icon" href="<%=path%>/static/favicon.ico">
    <link rel="img" href="<%=path%>/static/img/bg.jpg">
    <link rel="stylesheet" href="<%=path%>/static/bootstrap/css/bootstrap.css" >
    <link rel="stylesheet" href="<%=path%>/static/bootstrap/css/bootstrap.css/bootstrap.min.css" >
    <link rel="stylesheet" href="<%=path%>/static/admin/css/index.css" >
    <link rel="stylesheet" href="<%=path%>/static/admin/css/main.css" >
    <link rel="stylesheet" href="<%=path%>/static/admin/css/html.css" >
    <script src="<%=path%>/static/js/vue.min.js"></script>
    <script src="<%=path%>/static/js/jquery-3.3.1.min.js" ></script>
    <script src="<%=path%>/static/bootstrap/js/bootstrap.bundle.js" ></script>
    <script src="<%=path%>/static/admin/js/script.js" ></script>
    <script>
        $(function () {
            let hrefArr = window.location.href.split('/');
            let name = hrefArr[hrefArr.length-1];
            $(".menu a[href='"+name+"']").addClass('active');
        })
    </script>
</head>
<body>

<div id="app" class="d-flex">

    <nav>
        <div class="logo">
            <h4>BsAdmin</h4>
        </div>
        <ul class="menu">
             <li><a href="<%=path%>/stu/index"><i class="iconfont mr-1">&#xe6a2;</i>首页</a> </li> <li><a class="top-menu" href="javascript:;"><i class="iconfont mr-1">&#xe6e0;</i>系统管理<i class="iconfont arrow float-right">&#xe66c;</i></a><ul class="sub-menu"><li><a href="<%=path%>/stu/query" >用户列表</a></li><li><a href="<%=path%>/dept/query" >部门列表</a></li></ul> </li>
        </ul>
    </nav>

    <main>
        <header>
            <a href="http://www.qadmin.net" target="_blank">网站首页</a>

            <div class="dropdown float-right">
                <button class="btn  btn-sm  dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <svg width="20" height="1em" viewBox="0 0 16 16" class="bi bi-emoji-smile-fill rounded-circle" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                        <path fill-rule="evenodd" d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zM7 6.5C7 7.328 6.552 8 6 8s-1-.672-1-1.5S5.448 5 6 5s1 .672 1 1.5zM4.285 9.567a.5.5 0 0 1 .683.183A3.498 3.498 0 0 0 8 11.5a3.498 3.498 0 0 0 3.032-1.75.5.5 0 1 1 .866.5A4.498 4.498 0 0 1 8 12.5a4.498 4.498 0 0 1-3.898-2.25.5.5 0 0 1 .183-.683zM10 8c.552 0 1-.672 1-1.5S10.552 5 10 5s-1 .672-1 1.5S9.448 8 10 8z"/>
                    </svg>
                    <!--可以使用图片,大小20,class='rounded-circle'-->
                    BsAdmin
                </button>

                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu2">
                    <a class="dropdown-item" href="repwd.html">修改密码</a>
                    <a class="dropdown-item" href="out.html">退出登录</a>
                </div>
            </div>

        </header>

        <div id="body">
            

<main>
    <div class="main">
        <div class="search">
            <form class="form-inline float-left" action="<%=path%>/stu/query" method="post">
                <div class="form-group">
                    <input type="text" id="id" name="name" value="${name}" class="form-control" placeholder="手机号/昵称/UID">
                </div>
                <input  type="submit" class="btn btn-primary" value="搜索" />
            </form>


            <a class="btn btn-primary float-right" href="<%=path%>/stu/perAdd">新增</a>
            <a class="btn btn-primary float-right" id="delbtn">删除</a>
        </div>

        <div class="table-box ">
            <table class="table ">
                <thead>
                <tr>
                    <th >
                        <input type="checkbox" id="ck">
                    </th>
                    <th scope="col">姓名</th>
                    <th scope="col">年龄</th>
                    <th scope="col">部门</th>
                    <th scope="col">职位</th>
                    <th scope="col">联系方式</th>
                    <th scope="col">签到</th>
                    <th scope="col">操作</th>
                </tr>
                </thead>
                <tbody >
               
                <jsp:useBean id="smn" scope="request" type="com.li.util.PageUtils"/>
                <c:forEach items="${smn.list}" var="a">
                   <tr>
                       <td ><input type="checkbox" value="${a.id}" class="cks" ></td>
                       <td name="username">${a.getUsername()}</td>
                       <td name="age" >${a.getAge()}</td>
                       <td name="banme">${a.getBname()}</td>
                       <td></td>
                       <td></td>
                       <td></td>
                       <td style="align-self: center">
                           <a class="btn btn-sm btn-primary" href="<%=path%>/stu/edit/?id=${a.getId()}">修改</a>
                           <a class="btn btn-sm btn-danger" href="<%=path%>/stu/del/?id=${a.getId()}">删除</a>
                       </td>
                  </tr>
               </c:forEach>
                </tbody>
            </table>
        </div>
        <div class="page" style="margin: 0px 0px 0px 350px;">
            <span class="total float-left page-link" id="tiao">共${smn.totalCount } 条</span>
            <span class="total float-left page-link" id="ye">共${smn.totalPage}页</span>

            <ul class="pagination">
       <%--         <input type="hidden" name="curiPage" >

                <li class="page-item"><a class="page-link" href="<%=path%>/stu/query?curiPage=1">首页</a></li>
                <c:choose>
                    <c:when test="${smn.currPage >1}">
                        <li class="page-item"><a class="page-link" href="<%=path%>/stu/query?curiPage=${smn.currPage-1}">上一页</a></li>
                    </c:when>
                    <c:when test="${smn.currPage ==1}">
                        <li class="page-item"><a class="page-link" >上一页</a></li>
                    </c:when>
                </c:choose>
                <li class="page-item"><a class="page-link" href="<%=path%>/stu/query?curiPage=${smn.currPage}">${smn.currPage }/ ${smn.totalPage}</a></li>
                <c:choose>
                    <c:when test="${smn.currPage ==1}">
                        <li class="page-item"><a class="page-link" href="<%=path%>/stu/query?curiPage=${smn.currPage+1}">下一页</a></li>
                    </c:when>
                    <c:when test="${smn.currPage+1 <= smn.totalPage}">
                        <li class="page-item"><a class="page-link" href="<%=path%>/stu/query?curiPage=${smn.currPage+1}">下一页</a></li>
                    </c:when>
                    <c:otherwise>
                        <li class="page-item"><a class="page-link" >下一页</a></li>
                    </c:otherwise>
                </c:choose>
                <li class="page-item"><a class="page-link" href="<%=path%>/stu/query?curiPage=${smn.totalPage}">尾页</a></li>
--%>
           <input type="hidden" id="pageNo">
           <li class="page-item"><a class="page-link" href="<%=path%>/stu/query?name=${name}&page=${(smn.currPage-1)<1?1:(smn.currPage-1)}">上一页</a></li>
           <!-- <li class="page-item"><a class="page-link" href="avascript:page('+a+');">a</a></li>
    -->
           <li class="page-item"><a class="page-link" href="<%=path%>/stu/query?name=${name}&page=${(smn.currPage+1)>smn.totalPage?smn.totalPage:(smn.currPage+1)}">下一页</a></li>
            </ul>
        </div>
    </div>
</main>


        </div>

    </main>
</div>

</body>
<script>
    $(function () {
        $("#ck").click(function () {
            var a =$(this).prop('checked');
            if(a){
                $(".cks").prop('checked',true);
            }else {
                $(".cks").prop('checked',false);
            }
        })

        $("#delbtn").click(function () {
            var arr =[];
            $(".cks:checked").each(function(){
                var id = $(this).val();
                arr.push(id);
            });
            window.location.href="<%=path%>/stu/dels?ids="+arr;
        })
    })
</script>
</html>
